
var Atalk_server_url = "http://api.local.abans.cn/atalk/index.php?a=abans/";


	jQuery("body").append('<div id="Atalk" class="atalk"><div id="Atalks" class="atalks"></div></div>');
	jQuery("#Atalks").append('<div id="Atalk_menu" class="atalk_menu"></div>');
	jQuery("#Atalk_menu").append('<a id="Atalk_menu_msg" class="atalk_menu_msg" onclick="Atalk_show(\'Atalk_body_msg\')">聊天</a>');
	jQuery("#Atalk_menu").append('<a id="Atalk_menu_nav" class="atalk_menu_nav" onclick="Atalk_show(\'Atalk_body_nav\')">导航</a>');
	
	
	jQuery("#Atalks").append('<div id="Atalk_body_msg" class="atalk_body_msg atalk_dis_none"></div>');
		jQuery("#Atalk_body_msg").append('<h2>消息</h2>');//标题
		jQuery("#Atalk_body_msg").append('<div id="Atalk_msg" class="atalk_msg"></div>');//信息显示
		jQuery("#Atalk_body_msg").append('<textarea id="Atalk_content"></textarea>');//发送内容
		jQuery("#Atalk_body_msg").append('<div id="Atalk_btn" class="atalk_btn"></div>');//信息按钮
			jQuery("#Atalk_btn").append('<a>表情</a>');
			jQuery("#Atalk_btn").append('<input type="submit" onsubmit="Atalk_tomsg()" value="发送">');


	Atalk_getmsg();//获取信息

function Atalk_run(){
	setTimeout('Atalk_getmsg()',1000);
}


//Atalk_getmsg();
function Atalk_show(str){
	jQuery("#"+str).toggleClass("atalk_dis_none");
}




//获取消息
function Atalk_getmsg(){
	var msg;
	jQuery.ajax({
		type: "GET",
		url: Atalk_server_url,
		data: "",
		success: function(data){
			if(data == 'no'){
				msg_html = "<p>没有信息</p>";
			}else{
				var msg_html;
				for(val in data){
					if(msg_html==""){
						msg_html = "<p>"+data['username']+":"+data['msg']+"</p>";
					}else{
						msg_html += "<p>"+data['username']+":"+data['msg']+"</p>";
					}
				}
				jQuery("#Atalk_msg").append(decodeURI(msg_html));
				jQuery("#Atalk_msg").animate({scrollTop:jQuery("#Atalk_msg").offset().top+10000}, 1000);
			}
			Atalk_run();
		}
	})
}
//发送消息
function Atalk_tomsg(){
	var ipss = jQuery(".ajax_iplists_"+ipid).html();

		jQuery.ajax({
			type: "POST",
			url: Atalk_server_url,
			data: "&ip="+value+"&ipid="+ipid+"&times="+times,
			success: function(data){
				
				jQuery("#ajax_iplist_"+ipid).after(data);
			}
		})

}